﻿namespace ZhiJiao.Service.Dto
{

    #region BackJson

    /// <summary>
    /// 统一返回结果
    /// </summary>
    public class BackJson
    {
        public BackJson()
        {
            msg = string.Empty;
            err = string.Empty;
        }

        #region
        /// <summary>
        /// 返回码 0表示成功 
        /// </summary>
        public int code { get; set; }

        /// <summary>
        /// 提示信息
        /// </summary>
        public string msg { get; set; }

        /// <summary>
        /// 错误信息对象
        /// </summary>
        public object err { get; set; }

        /// <summary>
        /// 返回数量
        /// </summary>
        public int count { get; set; }

        /// <summary>
        /// 返回数据对象
        /// </summary>
        public object data { get; set; }

        #endregion

        #region 方法

        /// <summary>
        /// 保存成功返回{code:0, msg:"保存成功"}
        /// </summary>
        public void SaveSuccess()
        {
            code = 0;
            msg = "保存成功！";
        }

        /// <summary>
        /// 添加成功返回{code:0, msg:"添加成功"}
        /// </summary>
        public void AddSuccess()
        {
            code = 0;
            msg = "添加成功！";
        }

        /// <summary>
        /// 设置值
        /// </summary>
        /// <param name="c">code，返回码</param>
        /// <param name="m">msg，消息内容</param>
        /// <param name="e">err，错误信息</param>
        public void SetVal(int c, string m, string e = "")
        {
            code = c;
            msg = m;
            err = e;
        }

        /// <summary>
        /// 设置值
        /// </summary>
        /// <param name="c">code，返回码</param>
        /// <param name="m">msg，消息内容</param>
        /// <param name="e">err，错误信息</param>
        /// <param name="d">data，数据object</param>
        public void SetVal(int c, string m, string e, object d)
        {
            code = c;
            msg = m;
            err = e;
            data = d;
        }

        /// <summary>
        /// 设置值
        /// </summary>
        /// <param name="c">code，返回码</param>
        /// <param name="m">msg，消息内容</param>
        /// <param name="e">err，错误信息</param>
        /// <param name="t">count，total：用于表格获取数据总数</param>
        /// <param name="d">data，数据object</param>
        public void SetVal(int c, string m, string e, int t, object d)
        {
            code = c;
            msg = m;
            err = e;
            count = t;
            data = d;
        }

        ///// <summary>
        ///// 返回（您无权进行此操作！）
        ///// </summary>
        //public void NoPowerAction()
        //{
        //    code = 110;
        //    msg = StaticConfigModel.CHECK_POWER_FAIL_ACTION_MESSAGE;
        //}

        ///// <summary>
        ///// 返回（您无权访问此页面！）
        ///// </summary>
        //public void NoPowerPage()
        //{
        //    code = 110;
        //    msg = StaticConfigModel.CHECK_POWER_FAIL_PAGE_MESSAGE;
        //}
        #endregion
    }

    #endregion


    #region BackCode

    /// <summary>
    /// API返回代码
    /// </summary>
    public enum BackCode
    {
        /// <summary>
        /// 0： 执行成功
        /// </summary>
        SUCCESS = 0,
        /// <summary>
        /// 100： 商户参数错误
        /// </summary>
        MCH_ERR = 100,
        /// <summary>
        /// 120： 签名错误
        /// </summary>
        SIGN_INVALID = 120,

        /// <summary>
        /// 130： 传输数据错误
        /// </summary>
        PASS_DATA_ERR = 130,

        /// <summary>
        /// 140：传递参数有误
        /// </summary>
        PASS_PARAM_ERR = 140,

        /// <summary>
        /// 150：内部处理数据出错(服务器端错误)
        /// </summary>
        SERVER_ERR = 150,

        /// <summary>
        /// 160： 验证数据完整性失败
        /// </summary>
        DATA_INVALID = 160,

        /// <summary>
        /// 170： TS无效 timespan|timestamp
        /// </summary>
        TIMESTAMP_INVALID = 170,

        /// <summary>
        /// 180： token错误
        /// </summary>
        TOKEN_INVALID = 180,

        /// <summary>
        /// 190：调用无权限
        /// </summary>
        NO_PERMISSION = 190,

        /// <summary>
        /// 200： 调用超过频率
        /// </summary>
        MORE_THAN_LIMIT_COUNT = 200

    }

    #endregion


}
